﻿using Sx.Mall.Web.Filter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace Sx.Mall.Web.Filter
{
    public class MemberFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {

            if (filterContext.ActionDescriptor.ActionName == "Login" && filterContext.ActionDescriptor.ControllerDescriptor.ControllerName == "Admin")
            {

            }
            else if (filterContext.ActionDescriptor.ControllerDescriptor.ControllerName == "Home")
            {

            }
            else
            {
                if (LoginHelper.IsLogin())
                {
                    base.OnActionExecuting(filterContext);
                }
                else
                {
                    //var url = filterContext.HttpContext.Request.ServerVariables["Url"];
                    //filterContext.Result = new RedirectResult(FormsAuthentication.DefaultUrl);
                    filterContext.Result = new RedirectResult("/Admin/Login");
                }
            }
        }
    }
}